const get = {
    msg: '成功',
    data: {
        'shoppingCartList': [
            {
                'id': '1',
                "name": '精纺美利奴羊毛圆领针织衫',
                'color': '01 乳白色',
                'size': '150/76A/XS',
                'price': '149.00',
                'number': 1,
            },
            {
                'id': '2',
                "name": '精纺美利奴羊毛圆领针织衫',
                'color': '01 乳白色',
                'size': '150/76A/XS',
                'price': '182.00',
                'number': 2,
            },
        ]
    }
}

const {data: {shoppingCartList}} = get

function ShoppingCartRender() {
    let str = ''
    let all = 0
    let totalPrice = 0
    for (let i = 0; i < shoppingCartList.length; i++) {
        const ds = shoppingCartList[i]
        str += `
        <tr>
            <th scope="row">${ds.id}</th>
            <td>${ds.name}</td>
            <td>${ds.color}/${ds.size}</td>
            <td>${ds.price}</td>
            <td>${ds.number}</td>
            <td>${(ds.number * ds.price).toFixed(2)}</td>
            <td></td>
        </tr>
    `
        all += ds.number
        totalPrice += +(ds.number * ds.price).toFixed(2)
        document.querySelector('tfoot [data-name="all"]').innerHTML = `总计：${all}`
        document.querySelector('tfoot [data-name="totalPrice"]').innerHTML = `总价：${totalPrice.toFixed(2)}`
    }
    document.querySelector('tbody').innerHTML = str
}

ShoppingCartRender()